package com.design.memento.text;

public class MementoTextEditorDemo {
    public static void main(String[] args) {
        TextEditor textEditor = new TextEditor();
        Caretaker caretaker = new Caretaker();

        textEditor.append("Hello, ");
        caretaker.addMemento(textEditor.save());

        textEditor.append("world!");
        caretaker.addMemento(textEditor.save());

        System.out.println("Current Content: " + textEditor.getContent());

        textEditor.restore(caretaker.getMemento(0));
        System.out.println("Restored Content: " + textEditor.getContent());
    }
}
